import { Strategy } from '@/libs/strategy';
import { OtherOptions, RouteRecordRaw } from 'vue-router';

const strategy = new Strategy();

strategy.add('patchRouteOptions', (route: RouteRecordRaw, routeOptions: RouteRecordRaw) => {
  for (const key in routeOptions) {
    //@ts-ignore
    route[key] = routeOptions[key];
  }
});

strategy.add('patchOtherOptions', (route: RouteRecordRaw, otherOptions: OtherOptions) => {
  if (otherOptions.params) {
    route.path = `${route.path}/:${otherOptions.params}`;
  }
});

strategy.add('patchChildren', () => {});

export default strategy;
